org.eclipse.jface.text.formatter
Class ContextBasedFormattingStrategy
java.lang.Object
org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy
- All Implemented Interfaces:
- IFormattingStrategy, IFormattingStrategyExtension
- public abstract class ContextBasedFormattingStrategy
- extends Object
- implements IFormattingStrategy, IFormattingStrategyExtension
Formatting strategy for context based content formatting.
This strategy implements IFormattingStrategyExtension
. It
must be registered with a content formatter implementing IContentFormatterExtension2
to take effect.
- Since:
- 3.0
- See Also:
IContentFormatterExtension2
,
IFormattingStrategyExtension
Method Summary |
void |
format()
Formats the region with the properties indicated in the formatting
context previously supplied by formatterStarts(IFormattingContext) . |
String |
format(String content,
boolean isLineStart,
String indent,
int[] positions)
Formats the given string. |
void |
formatterStarts(IFormattingContext context)
Informs the strategy about the start of a formatting process in which it
will participate. |
void |
formatterStarts(String initialIndentation)
Informs the strategy about the start of a formatting process in which it will
participate. |
void |
formatterStops()
Informs the strategy that the formatting process in which it has participated
has been finished. |
Map |
getPreferences()
Returns the preferences to use during formatting. |
ISourceViewer |
getViewer()
Returns the source viewer to operate on. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ContextBasedFormattingStrategy
public ContextBasedFormattingStrategy(ISourceViewer viewer)
- Creates a new abstract formatting strategy.
- Parameters:
viewer
- ISourceViewer to operate on
format
public void format()
- Description copied from interface:
IFormattingStrategyExtension
- Formats the region with the properties indicated in the formatting
context previously supplied by
formatterStarts(IFormattingContext)
.
- Specified by:
format
in interface IFormattingStrategyExtension
format
public String format(String content,
boolean isLineStart,
String indent,
int[] positions)
- Description copied from interface:
IFormattingStrategy
- Formats the given string. During the formatting process this strategy must update
the given character positions according to the changes applied to the given string.
- Specified by:
format
in interface IFormattingStrategy
- Parameters:
content
- the initial string to be formattedisLineStart
- indicates whether the beginning of content is a line start in its documentindent
- the indentation string to be usedpositions
- the character positions to be updated
- Returns:
- the formatted string
formatterStarts
public void formatterStarts(IFormattingContext context)
- Description copied from interface:
IFormattingStrategyExtension
- Informs the strategy about the start of a formatting process in which it
will participate.
- Specified by:
formatterStarts
in interface IFormattingStrategyExtension
- Parameters:
context
- Formatting context used in the corresponding formatting
process.
formatterStarts
public void formatterStarts(String initialIndentation)
- Description copied from interface:
IFormattingStrategy
- Informs the strategy about the start of a formatting process in which it will
participate.
- Specified by:
formatterStarts
in interface IFormattingStrategy
- Parameters:
initialIndentation
- the indent string of the first line at which the
overall formatting process starts.
formatterStops
public void formatterStops()
- Description copied from interface:
IFormattingStrategy
- Informs the strategy that the formatting process in which it has participated
has been finished.
- Specified by:
formatterStops
in interface IFormattingStrategy
getPreferences
public final Map getPreferences()
- Returns the preferences to use during formatting.
- Returns:
- The formatting preferences
getViewer
public final ISourceViewer getViewer()
- Returns the source viewer to operate on.
- Returns:
- The source viewer to operate on
Copyright (c) IBM Corp. and others 2000, 2003. All Rights Reserved.